package cn.antblog.dealData.main;

import cn.antblog.dealData.entity.Dwd2p06SgscxsrFcpBigdata;
import cn.hutool.core.bean.BeanUtil;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author yangjy
 * @version 1.0
 * @description: 处理数据
 * @date 2022/11/21 10:19
 */
public class DealData {


    public static void main(String[] args) {
        new DealData().dealWithData();
    }


    public void dealWithData() {
        List<Dwd2p06SgscxsrFcpBigdata> list = new ArrayList<>();
        Dwd2p06SgscxsrFcpBigdata data = new Dwd2p06SgscxsrFcpBigdata();
        data.setCycleId("202210");
        data.setCityName("河北");
        data.setBnlj(new BigDecimal(0.0000));
        data.setSntq(new BigDecimal(0.0200));
        data.setTbzfPaiming(new BigDecimal(1.1234));
        list.add(data);
        for (Dwd2p06SgscxsrFcpBigdata bigdata : list) {

            bigdata.forEach(
                    (key, val) -> {
                        System.out.println(key);
                        System.out.println(val);
                        if (val instanceof BigDecimal) {
                            BigDecimal decimal = new BigDecimal(String.valueOf((BigDecimal) val));
                            BigDecimal bigDecimal = decimal.setScale(2, BigDecimal.ROUND_HALF_UP);
                            val = bigDecimal;
                            HashMap<String, Object> map = new HashMap<>();
                            map.put(key, val);
                            BeanUtil.fillBeanWithMapIgnoreCase(map, bigdata, false);
                        }
                    }
            );
        }

        System.out.println(list.toString());
    }


}
